Skip to content

Write and read CrankNicolson's restart state - #109

Merged
tihiera merged 2 commits into
developfrom
fix/cn-restart
Nov 28, 2026
Merged

tihiera merged 2 commits into
developfrom
fix/cn-restart

Conversation

@tihiera

@tihiera tihiera commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

A pimpleFoam restart under CrankNicolson continues the run as OpenFOAM's does. brae now writes and reads the old levels and CrankNicolson's ddtCorr fields, and OpenFOAM can now restart from brae's CrankNicolson write at all. Follows #108.

OpenFOAM:

  • Under CrankNicolson, fvmDdt asks for every field's old-old level unconditionally, so U_0, k_0 and epsilon_0 are written from the first step (GeometricField.C:923-940). phi_0 is written from the step after ddtCorr creates phi's old-old level.
  • ddtCorrDdt0(U) and ddtCorrDdt0(phi) are AUTO_WRITE from their creation.
  • A restart reads each. A DDt0Field read so has startTimeIndex_ -2, so both coefficients are 1 + ocCoeff at once, and it is evaluated on the first restarted step from the old levels read (CrankNicolsonDdtScheme.C:48-61, 102-165).

brae before:

  • OpenFOAM could not restart from brae's write. ddt0(k) and ddt0(epsilon) were written dimensionless ("Different dimensions for '(a - b)'").
  • None of the files above were written, and the old levels were not seeded, so the first restarted step skipped its ddt0 update.
  • pitzDaily at CrankNicolson 0.9, against OpenFOAM's continuous run from the third step: brae from its own write or from OpenFOAM's was off by 27 (p).
  • writeVolFieldRaw took boundary values and ignored them, writing every calculated patch as uniform 0.

Change:

  • ddt0(...) files carry their field's dimensions over time.
  • Under CrankNicolson the writer adds U_0, k_0, epsilon_0/omega_0/nuTilda_0, phi_0 (from the step OpenFOAM starts writing it) and ddtCorrDdt0(U|phi) with their patch values.
  • A restart from index 1 or more whose start carries ddt0(U) seeds the old levels as Write and read backward's old levels across restarts #105 does for backward (renamed setOldLevelsRestart). Without ddt0(U), OpenFOAM's restart is a cold CrankNicolson start, and so is brae's.
  • ddtCorrDdt0(U|phi) are read as a pair, with start index -2. phi's old-old level counts as existing when phi_0 was read.
  • deltaT0 is Time's deltaTSave_, as for backward.
  • writeVolFieldRaw writes the boundary values it is given.
  • The recurrence takes o - oo before scaling, as OpenFOAM does; scaling first left 3e-17 where OpenFOAM writes 0.
  • Controls:
    • BRAE_CONTROL_CN_NO_CORR_RESTART=1: the ddtCorr fields are neither written nor read;
    • BRAE_CONTROL_BACKWARD_NO_OLD_READ=1 (now either scheme): the old levels are not seeded.

Gate: tests/pimple_cranknicolson_vs_openfoam.sh gains restart arms for C9 (CrankNicolson 0.9), restarting from the third step and judged within the gate's 1e-8:

Arm Before (develop ecaa29ed) After
W: files at the third step missing U_0 phi_0 k_0 epsilon_0 ddtCorrDdt0(U|phi) OpenFOAM's set; values within 1.5e-10; ddt0(U|k) 1.6e-11
R: brae from its own write 2.7e+01 3.2e-09
O: brae from OpenFOAM's write 2.7e+01 1.0e-10
B: OpenFOAM from brae's write cannot start 3.3e-09
  • The premise holds: OpenFOAM's own restart equals its continuous run.
  • Controls: 1.8e+01 (ddtCorr fields), 2.7e+01 (old levels).
  • R and B sit at the continuous run's p floor (3.2e-09).
  • ddt0(epsilon) is held off the 472 cells next to an epsilonWallFunction patch (1.5e-12). At those cells it is 1.8e-02, which is reported: OpenFOAM's first-step epsilon_0 is the copy oldTime() makes after the wall function has set those cells, and the epsilon equation replaces their rows with the wall function's values.

Regressions (one GH200; this branch against develop ecaa29ed, built and run on the same node, one tree at a time):

  • The CrankNicolson gate, restart arms included, passes as registered on this branch. On develop's binaries the same script reads R and O at 2.7e+01, B cannot start, and W fails.
  • 30 tests on each tree, all passing on both: every pimpleFoam, DES, ddt, restart, backward and CrankNicolson test (the backward restart gate through the renamed setOldLevelsRestart included), plus the registration and audit tests.

Not covered:

  • brae writes ddt0's patch values as zero. OpenFOAM's fvmDdt reads only the internal field.
  • The wall-function cells' ddt0(epsilon) and ddt0(omega) differ, as above.
  • A moving mesh and cyclic or AMI interfaces still omit CrankNicolson's ddtCorr, so they write no ddtCorrDdt0 files.

No tolerance was changed.

@tihiera
tihiera merged commit 43ce161 into develop Nov 28, 2026
6 checks passed
@tihiera
tihiera deleted the fix/cn-restart branch November 28, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant